<?php
header("Content-type: application/json");

require_once("model/Player.php");
require_once("bizlayer/datamigration_mgmt.php");


if(isset($_POST) and $_SERVER["REQUEST_METHOD"] == "POST"){
	$origPlayer = new Player();
	$newPlayer = new Player();
	
	$origPlayer->firstName = (isset($_POST["origFirst"]) && trim($_POST["origFirst"]) != "")?trim($_POST["origFirst"]):null;
	$origPlayer->lastName =  (isset($_POST["origLast"]) && trim($_POST["origLast"]) != "")?trim($_POST["origLast"]):null;
	$origPlayer->emailAddress =  (isset($_POST["origEmailAddr"]) && trim($_POST["origEmailAddr"]) != "")?trim($_POST["origEmailAddr"]):null;
	$newPlayer->firstName = (isset($_POST["newFirst"]) && trim($_POST["newFirst"]) != "")?trim($_POST["newFirst"]):null;
	$newPlayer->lastName =  (isset($_POST["newLast"]) && trim($_POST["newLast"]) != "")?trim($_POST["newLast"]):null;
	$newPlayer->emailAddress =  (isset($_POST["newEmailAddr"]) && trim($_POST["newEmailAddr"]) != "")?trim($_POST["newEmailAddr"]):null;
	
	
	echo DataMigrationMgmt::updatePlayer($origPlayer,$newPlayer);
}
else{
	echo "{\"status\":\"wasn\'t sent via POST method.\"}";
}
?>
